import Cookies from 'js-cookie'

const TokenKey = 'vue_admin_template_token'

// export function getToken() {
//   return Cookies.get(TokenKey)
// }

// export function setToken(token) {
//   return Cookies.set(TokenKey, token)
// }

// export function removeToken() {
//   return Cookies.remove(TokenKey)
// }
export function getToken(num =2) {
  const url = window.location.href
  const index = url.indexOf('tk=')
  if (index !== -1) {
    const token = url.substring(index + 3)
    console.log(token,"token---")
    sessionStorage.setItem('summary', token)
    setToken(token)
  }
  return sessionStorage.getItem(TokenKey)
}


export function setToken(token) {
  return sessionStorage.setItem(TokenKey, token)
}

export function removeToken() {
  const url = window.location.href
  const index = url.indexOf('tk=')
  if (index !== -1) {
    window.location.href = url.slice(0, index)
  }
  return sessionStorage.removeItem(TokenKey)
}
